﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/HomeSite.Master" Inherits="System.Web.Mvc.ViewPage<TimeTableManagement.Entities.Tb_People>" %>

<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxTabControl" TagPrefix="dx" %>

<%@ Register assembly="DevExpress.Web.v11.1, Version=11.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxClasses" tagprefix="dx" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<script src="<%: Url.Content("~/Scripts/jquery.validate.min.js") %>" type="text/javascript"></script>
<script src="<%: Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js") %>" type="text/javascript"></script>

<% using (Html.BeginForm()) { %>
    <%: Html.ValidationSummary(true) %>
    <dx:ASPxPageControl ID="ASPxPageControl1" runat="server" ActiveTabIndex="0" 
        Width="100%" CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua" 
        SpriteCssFilePath="~/App_Themes/Aqua/{0}/sprite.css" TabSpacing="3px">
        <TabPages>
            <dx:TabPage Text="Student">
                <ContentCollection>
                    <dx:ContentControl ID="ContentControl1" runat="server" SupportsDisabledAttribute="True">
<%----------------------------Noi dung tab 1--%>

                    <%: Html.HiddenFor(model => model.id) %>

                    <div class="editor-label">
                        <%: Html.LabelFor(model => model.mssv,"Code Lecturer") %>
                    </div>
                    <div class="editor-field">
                        <%: Html.EditorFor(model => model.mssv) %>
                        <%: Html.ValidationMessageFor(model => model.mssv) %>
                    </div>

                    <div class="editor-label">
                        <%: Html.LabelFor(model => model.name,"Name") %>
                    </div>
                    <div class="editor-field">
                        <%: Html.EditorFor(model => model.name) %>
                        <%: Html.ValidationMessageFor(model => model.name) %>
                    </div>

                    <div class="editor-label">
                        <%: Html.LabelFor(model => model.id_department, "Department") %>
                    </div>
                    <div class="editor-field">
                        <%: Html.DropDownList("id_department", String.Empty) %>
                        <%: Html.ValidationMessageFor(model => model.id_department) %>
                    </div>

                    <%: Html.HiddenFor(model => model.type) %>

                   
                    </dx:ContentControl>
                </ContentCollection>
            </dx:TabPage>
            <dx:TabPage Text="Profile">
                <ContentCollection>
                    <dx:ContentControl ID="ContentControl2" runat="server" SupportsDisabledAttribute="True">
<%---------------------------Nội dung tab 2--%>
                    <% 
                        TimeTableManagement.QLSVContext db = new TimeTableManagement.QLSVContext();
                        var list = db.Tb_Profile_Value.Where(g => g.Tb_Config.option.Equals("profile")).Where(g => g.id_person == Model.id).ToList();
                       foreach (TimeTableManagement.Entities.Tb_Profile_Value item in list)
                       { %>
                        <div class="display-label"><%: Html.Label(item.Tb_Config.displayword) %></div>
                        <div class="display-field">
                            <input id="<%:item.id %>" keyword="<%: item.Tb_Config.keyword %>"
                            class="lectureritem" name="<%: item.Tb_Config.displayword %>" type="text" value="<%: item.value %>"/>
                            
                        </div>
                       <% } %>
                        </dx:ContentControl>
                </ContentCollection>
            </dx:TabPage>
        </TabPages>
        <LoadingPanelImage Url="~/App_Themes/Aqua/Web/Loading.gif">
        </LoadingPanelImage>
        <Paddings Padding="2px" PaddingLeft="5px" PaddingRight="5px" />
        <ContentStyle>
            <Border BorderColor="#AECAF0" BorderStyle="Solid" BorderWidth="1px" />
        </ContentStyle>
    </dx:ASPxPageControl>
        <input id="profile" name="profile" type="hidden" />
        <%--Can mot javascript, khi bam nut Save thi cap nhat gia tri cho hidden profile--%>
     <p>
         
     <input type="submit" value="Save" onclick="return updatejson()" />
     </p>

<% } %>

<div>
    <%: Html.ActionLink("Back to List", "Index") %>
</div>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="HeadContent" runat="server">
<script>
    function updatejson() {
        $json = "";
        $items = document.getElementsByClassName('lectureritem');
        for ($i = 0; $i < $items.length; $i++) {
            $item = $items.item($i);
            $id = $item.id;
            $keyword = $item.getAttribute('keyword');
            $value = $item.value;
            $value = $value.replace(/^\s+|\s+$/g, "");
            $json = $json + ',{"id":' + $id + ',"key":"' + $keyword + '","value":"' + $value + '"}';
        }
        $json = '[' + $json.substr(1) + ']';
        document.getElementById('profile').value = $json;
        return true;
    }
</script>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="leftmenu" runat="server">
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="menuright" runat="server">
</asp:Content>

<asp:Content ID="Content5" ContentPlaceHolderID="Footer" runat="server">
</asp:Content>
